package tinynio;

import java.io.IOException;

public class LogHandler implements Handler {

	@Override
	public void onActive(Communicator communicator) {
		System.out.println("active");
	}

	@Override
	public void onRead(Communicator communicator, Object msg) {

		System.out.println("read " + msg.toString());
		try {
			communicator.write("hello from lightNIO");
			System.out.println("=======");
			communicator.flush();
			System.out.println("===22====");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void onClose(Communicator communicator) {
		System.out.println("close");
	}

	@Override
	public void onError(Communicator communicator, Throwable cause) {
		cause.printStackTrace();
	}

}
